package normal;

import cn.hutool.core.lang.Console;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * <p>类描述</p>
 * Copyright: Copyright (C) 2024 YBT, Inc. All rights reserved.
 * @author zhuqi
 * @since 2024/5/22 14:31
 */
public class LocalDateTime {

    public static void test() {
        Date date = new Date();
        Console.log("当前时间:{}", date.getTime());
         boolean b = LocalDateTime.validDelayTime("1716426202765");
//        boolean b = LocalDateTime.validDelayTime(String.valueOf(date.getTime()));
        Console.log("判断是否超过时间:{}", b);
    }

    public static boolean validDelayTime(String timestamp) {
        long diffInMillis = System.currentTimeMillis() - Long.parseLong(timestamp);
        long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffInMillis);

        // 判断是否超过5分钟
        return diffInMinutes >= 5;
    }

    public static void main(String[] args) {
        // getTime();

        test();
    }

    public static void getTime() {
        java.time.LocalDateTime startTime =  java.time.LocalDateTime.now();
        java.time.LocalDateTime endTime =  java.time.LocalDateTime.now().withYear(2025).withMonth(1).withDayOfYear(1).withHour(23).withMinute(59).withNano(0).withSecond(0);
        Console.log("startTime:{}", startTime);
        Console.log("endTime:{}", endTime);
    }
}
